package com.hl.mapper;

import com.hl.pojo.Article;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ArticleMapper {
    @Insert("insert into article (article_name, article_intro, consultant_id, list_image, detail_content, category_id, create_time) value (#{articleName},#{articleIntro},#{consultantId},#{listImage},#{detailContent},#{categoryId},#{createTime})")
    Integer add(Article article);

    @Update("update article set article_name=#{articleName},article_intro=#{articleIntro},consultant_id=#{consultantId},list_image=#{listImage},detail_content=#{detailContent} where id=#{id}")
    Integer update(Article article);
    @Update("update article set del = 1 where id = #{id}")
    Integer del(Integer id);
    @Select("select * from article where del !=1")
    List<Article> findAll();
    @Select("select * from article where article_name = #{articleName} and del !=1")
    List<Article> findByName(Article article);
    @Select("select * from article where category_id = #{categoryId} and del !=1")
    List<Article> findByCategory(Integer categoryId);
    @Select("select * from article where consultant_id = #{consultantId} and del !=1")
    List<Article> findByConsultantId(Integer consultantId);
}
